#ifndef MUX_HANDLER
#define MUX_HANDLER

#include "tools.h"
#include "muxer.h"
#include "avpacket_list.h"
#include "thread_handler.h"

namespace lcf
{
    class MuxHandler : public ThreadHandler
    {
    public:
        MuxHandler() {}
        ~MuxHandler() {}
        void Main();

        /// 打开封装文件
        bool Open(const char *url,
                  AVCodecParameters *videoPara = nullptr,
                  AVRational *videoTimeBase = nullptr,
                  AVCodecParameters *audioPara = nullptr,
                  AVRational *audioTimeBase = nullptr);

        // 接收数据
        void HandleTask(AVPacket *pkt);

    private:
        Muxer muxer_;
        AVPacketList pkts_;
        std::mutex mtx_;
    };
}

#endif